<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <link rel="stylesheet" href="/print/_css/charge.css" />
    <title>科室申领详情</title>
</head>

<body>
    <div id="app" class="who_feed_print print_storage_box">
        <div v-for="(item,index) in list" class="print-pay_box">
            <div class="print-header-box" style="margin-top:7mm;padding-bottom: 2mm;">
                <h3 class="print_head_title_box">
                    <div class="print-logo_img">
                        <img  class="img-logo"  :src="logo" />
                    </div>
                    科室申领清单
                </h3>
                <!-- <p>
                    <span class="print_hospital_unit">制单人： {{detail.memberName}}</span>
                </p> -->
            </div>
            <table border="0" width="100%" class="storage_table">
                <tr>
                    <td style="text-indent:3mm">申领科室：{{detail.departmentName}}</td>
                    <td>申请医生：{{detail.doctorName}}</td>
                    <!-- <td>经手人：{{detail.operatorName}}</td> -->
                    <td>申请日期：{{detail.applyDate}}</td>
                    <td style="text-indent:3mm">出库日期：{{detail.outStockDate}}</td>
                    <td>出 库 人：{{detail.outStockName}}</td>
                </tr>
            </table>
            <div class="durg_content">
                <table class="durg_table storage_tab" border="0" width="100%">
                    <tr class="table-title thead_box">
                        <td style="text-indent:3mm">发票号</td>
                        <td style="width:11%;">药品名称</td>
                        <td>生产厂家</td>
                        <td>数量</td>
                        <td>单位</td>
                        <td>批号</td>
                        <td style="width:11%;">国药准字号</td>
                        <td style="width:11%;">有效期</td>
                        <td>成本价</td>
                        <td>成本合计</td>
                    </tr>
                    <tr v-for="(items,index2) in item.list" class="tr-item">
                        <td style="text-indent:3mm">{{items.invoiceNumber}}</td>
                        <td style="width:11%;">{{items.drugName}}</td>
                        <td>{{items.factory}}</td>
                        <td>{{items.applyNum}}</td>
                        <td>{{items.packUnit}}</td>
                        <td>{{items.lotNumber}}</td>
                        <td style="width:11%;">{{items.chineseMedicine}}</td>
                        <td style="width:11%;">{{items.effectiveTime}}</td>
                        <td>{{items.costMoney}}</td>
                        <td>{{items.sellMoney}}</td>
                    </tr>
                </table>
            </div>
            <div class="print_footer_box" style="margin-top:10mm;">
                <!-- <p style="text-indent:0mm">
                    合计数量：{{item.allNum}}
                </p> -->
                <p style="width:50%;">合计成本：￥{{item.sellMoney}}元</p>
            </div>
            <div class="print_footer_box" style="border-top:0px;">
                <p style="color: 101010;width:30%; font-size: 1mm;text-indent:0mm">
                    {{hospitalName}}
                </p>
                <p style="width: 32%;">经办人：{{detail.operatorName}}</p>
                <p style="width: 32%;">复核人：</p>
            </div>
        </div>
    </div>
    <!-- built files will be auto injected -->
    <script src="https://lib.baomitu.com/vue/2.6.10/vue.min.js"></script>
    <script>
        new Vue({
            data: {
                imgUrl: "https://bwzhyl.oss-cn-beijing.aliyuncs.com/",
                list: [],
                detail: "",
                logo: '',
                hospitalName: '',
                type:'',
                wayName:'',
                pageSize:12 //每页打印数量
            },
            mounted() {
                var th = this;
                window.addEventListener(
                    "message",
                    function (event) {
                        var obj = JSON.parse(event.data.params);
                        th.detail = obj.detail;
                        th.logo = obj.logo;
                        th.hospitalName = obj.hospitalName;
                        th.type=Number(obj.type);
                        th.detail.applyDate=th.changeTime(th.detail.applyDate)
                        th.detail.outStockDate=th.changeTime(th.detail.outStockDate)
                        var arr = [];
                        var list = [];
                        var sellMoney = 0;
                        var allNum = 0;
                        //如果是12的倍数就第二页
                        obj.list.forEach((item, index) => {
                            //let cost=item.costMoney  var priceDisplay = Number.parseFloat(cost) * Number.parseFloat(item.applyNum);
                            sellMoney += Number(item.totalCost);
                            item.packUnit=th.changeAssist(item.applyUnit,obj.dwList)
                            item.effectiveTime=th.changeTime(item.effectiveTime);
                            // item.sellMoney=Number.parseFloat(cost) * Number.parseFloat(item.applyNum).toFixed(2);
                            item.sellMoney=Number.parseFloat(item.totalCost);
                            arr.push(item);
                            var i = index + 1;
                            if (i % th.pageSize == 0) {
                                list.push({
                                    sellMoney: sellMoney.toFixed(2),
                                    title: "出库清单",
                                    allNum: allNum,
                                    list: arr
                                });
                                arr = [];
                                sellMoney = 0;
                            }
                        });
                        if (arr.length > 0) {
                            list.push({list: arr, sellMoney: sellMoney });
                        }
                        th.list = [...list];
                        //这里要判断图片是否加载完成
                        // let imgs = document.querySelectorAll("img-erweima");
                        var timer = setInterval(() => {
                            clearInterval(timer);
                            window.print();
                        }, 1000);
                    },
                    false
                );
            },
            methods: {
                changeTime(value) {
                    var str = ''
                    if (value) {
                        str = value.substring(0, 10)
                    }
                    return str;
                },
                changeAssist(value, list) {
                    for (var i = 0; i < list.length; i++) {
                        if (parseInt(value) == list[i].id) {
                            if (list[i].desc != undefined) {
                                str = list[i].desc;
                                break;
                            }
                        }
                    }
                    return str;
                },
            },
            watch: {},
            filters: {}
        }).$mount("#app");
    </script>
</body>

</html>